package com.jt.provider.controller;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
@Component
public class DefaultRequestOriginParser implements RequestOriginParser {
    /**
     * 这个方法中基于业务规则对请求数据进行解析
     */
    @Override
    public String parseOrigin(HttpServletRequest request) {
//        //对请求参数进行解析,并返回参数值,然后将这个值应用在sentinel的授权规则中
//        String origin = request.getParameter("origin");
//        return origin;
        // }
//        String token = request.getHeader("token");
//        return token;
        String ip=request.getRemoteAddr();
        System.out.println("ip"+ip);
        return ip;
    }
}
